package com.yh.lq.robot;

import com.yh.lq.boot.LQProperties;
import com.yh.lq.entity.ImType;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.socket.WebSocketSession;

/**
 * QQ mini 工厂类
 */
@Service
public class LQFactory {
    @Autowired
    private ApiHandler apiHandler;
    @Autowired
    @Getter
    private LQProperties lqProperties;


    /**
     * 创建一个CoolQ对象
     * 把spring容器中的apiHandler放入对象
     *
     * @param selfId     机器人自己的QQ号
     * @param botSession ws的session
     * @return CoolQ对象
     */
    public LQ createCoolQ(Long selfId, WebSocketSession botSession) {
        LQ lq = new LQ(String.valueOf(selfId), botSession, apiHandler, lqProperties.getPluginList());
        return lq;
    }

    /**
     * 创建机器人，带imType类型
     *
     * @param selfId
     * @param imType
     * @param botSession
     * @return
     */
    public LQ createRobot(String selfId, ImType imType, WebSocketSession botSession) {
        LQ lq = new LQ(selfId, imType, botSession, apiHandler, lqProperties.getPluginList());
        return lq;
    }
}
